import request from '../utils/request'

// 回答类型定义
export interface Message {
  messageId: number
  text: string
  creatorId: number
  messageBoardId: number
  userType: number
  createTime: string
  creatorName?: string // 前端展示需要
}

// 获取回答列表
export const getMessageList = (messageBoardId: number) => {
  return request<{
    code: string
    msg: string
    total: number
    data: Message[]
  }>({
    url: `/message/list/${messageBoardId}`,
    method: 'get'
  })
}

// 创建回答
export const createMessage = (data: {
  issueId: number
  creatorId: number
  text: string
  usertype: number
}) => {
  return request({
    url: '/message/create',
    method: 'post',
    params: {
      issueId: data.issueId,
      creatorId: data.creatorId,
      text: data.text,
      usertype: data.usertype
    }
  })
}
